<template>
  <!-- 短信管家 智能卡位 自动通话记录 -->
  <div class="app-container ">
    <div class="tipbox">
      当前为内测功能，请前往 “<span class="link" @click="goSet">设置管理>参数配置</span> ”进行设置
    </div>
          <el-form :model="queryParams" ref="queryForm" :inline="true" class=" search-form-new" label-width="80px">
           
            <el-form-item label="时间" prop="timer">
              <el-date-picker clearable v-model="timer" type="daterange" range-separator="至" value-format="yyyy-MM-dd" start-placeholder="开始日期" end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
            <!-- <el-form-item label="手机号" prop="phone">
              <el-input v-model="queryParams.phone" placeholder="请输入手机号" clearable size="small" />
            </el-form-item> -->
           
            <el-form-item class="btns">
              <el-button type="primary" icon="el-icon-search" @click="search" class="zdy-btn">搜索</el-button>
            </el-form-item>
          </el-form>
          <div class="table_box table_box_new">
            <el-table border stripe :data="tableData.records">
              <el-table-column prop="tenantName" label="归属商户" ></el-table-column>
              <el-table-column prop="createTime" label="时间" ></el-table-column>
              <el-table-column prop="param" label="号码" >
                <template slot-scope="scope">
                  <el-tooltip class="item" effect="dark" :content="scope.row.param" placement="top-start">
                    <div class="zdy-des">{{ scope.row.param }}</div>
                  </el-tooltip>
                </template>
              </el-table-column>
              <el-table-column prop="param" label="执行结果" >
                <template slot-scope="scope">
                  <el-tooltip class="item" effect="dark" :content="scope.row.res" placement="top-start">
                    <div class="zdy-des">{{ scope.row.res }}</div>
                  </el-tooltip>
                </template>
              </el-table-column>
              
              <el-table-column prop="state" label="状态" >
                <template slot-scope="scope">
                  <el-tag type="success" v-if="scope.row.state==1">成功</el-tag>
                  <el-tag type="danger" v-else>失败</el-tag>
                </template>
              </el-table-column>
          
            </el-table>
            <pagination v-show="tableData.total > 0" :total="tableData.total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize" @pagination="getList" />
          </div>
  </div>
</template>

<script>
import phoneApi from "@/api/phoneManage";
export default {
  name: "AutoCall",
  components: {  },
  data() {
    return {
      timer: [],
      tableData: {
        records: [],
        total: 0,
      },
      loading: false,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  created() {
    this.getList();
  },
  activated() {},
  methods: {

    // 获取列表
    getList() {
      this.loading = true;
      if (this.timer && this.timer.length) {
        this.queryParams.createTimeStart = this.timer[0] + " 00:00:00";
        this.queryParams.createTimeEnd = this.timer[1] + " 23:59:59";
      } else {
        this.queryParams.createTimeStart = "";
        this.queryParams.createTimeEnd = "";
      }
      phoneApi
        .telCallLoglist(this.queryParams)
        .then((response) => {
          this.tableData.records = response.rows;
          this.tableData.total = response.total;
          this.loading = false;
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    goSet(){
      this.$router.push({
        name:'ShopParams'
      })
    },

    // 搜索
    search() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    //重置
    resetQuery() {
      this.queryParams = {
        pageNum: 1,
        pageSize: 10,
        dataType: 1,
      };
      this.timer = [];
      this.getList();
    },
  },
};
</script>
<style lang="scss" scoped>
.tipbox{
  background: #f7f7f7;
  border-radius: 4px;
  padding: 5px 15px;
  color: #333;
  margin-bottom: 10px;
}
</style>